//
//  GovCenterService.m
//  homeland
//
//  Created by SunShine on 14-1-19.
//  Copyright (c) 2014年 xzysun. All rights reserved.
//

#import "GovCenterService.h"

@implementation GovCenterService

-(void)getWindowInfoForKey:(NSString *)key Success:(void (^)(NSArray *))success Failure:(void (^)(NSString *))failure
{
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    if ([key isEqualToString:@"区食品药品监督管理局"]) {
        key = @"区食品药品监管局";//取指南用的是监督管理局，取窗口用的是监管局
    }
    [params setValue:key forKey:@"unitName"];
    MKNetworkEngine *currentEngine = [[MKNetworkEngine alloc] initWithHostName:GOV_CENTER_AFFAIRS_LIST_URL customHeaderFields:nil];
    MKNetworkOperation *op = [currentEngine operationWithPath:@"" params:params httpMethod:@"POST"];
    [op addCompletionHandler:^(MKNetworkOperation *operation) {
        NSArray *json = [operation responseJSON];
        //转换对象,添加到列表中
        //执行回调
        success(json);
    }errorHandler:^(MKNetworkOperation *errorOp, NSError* err) {
        NSLog(@"MKNetwork request error : %@", [err localizedDescription]);
        //执行回调
        failure(@"请求窗口信息失败.");
    }];
    [currentEngine enqueueOperation:op];
}
@end
